package com.hd.mp.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hd.mp.domain.User;
import com.hd.mp.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class IndexController {

    @Autowired
    UserService userService;

    @RequestMapping("/test")
    public List<User> list(){
        List<User> list = userService.list();
        return list;
    }

    @RequestMapping("/page")
    public List<User> Page(){
        Page<User> page = new Page<>(2,20);
        IPage<User> pageinfo = userService.selectUserPage(page,null);
        System.out.println(pageinfo.getPages());
        System.out.println(pageinfo.getSize());
        System.out.println(pageinfo.getTotal());
        //........
        return pageinfo.getRecords();
    }

}
